$(() => {
    $("#btn-login").on('click', function () {
        let checked = document.getElementById("anonymous").checked;
        $.ajax({
            url: '/login',
            method: 'post',
            data: {
                email: $('#inputEmail').val(),
                password: $('#password').val(),
                anonymous: checked
            },
            success: function (res) {
                if (res.code == 0) {
                    if (res.data && res.data.length > 0) {
                        window.location.replace(res.data);
                        return;
                    }
                    window.location.replace("/index");
                } else {
                    alert('帐号或密码错误')
                }
            },
            error: function (err) {
                console.log(err);
            }
        })
    })
});